package com.atguigu.ssyx.product.service.impl;

import com.atguigu.ssyx.model.product.SkuPoster;
import com.atguigu.ssyx.product.mapper.SkuPosterMapper;
import com.atguigu.ssyx.product.service.SkuPosterService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 杨林
 * @create 2023-07-25 10:27 星期二
 * description:
 */
@Service
public class SkuPosterServiceImpl extends ServiceImpl<SkuPosterMapper, SkuPoster> implements SkuPosterService {
    
    @Autowired
    private SkuPosterMapper skuPosterMapper;


    /**
     * 根据skuId获取商品对应的海报信息
     * @param id
     * @return
     */
    @Override
    public List<SkuPoster> getListBySkuId(Long id) {
        LambdaQueryWrapper<SkuPoster> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SkuPoster::getSkuId,id);
        List<SkuPoster> skuPosters = skuPosterMapper.selectList(wrapper);
        return skuPosters;
    }

    /**
     * 根据skuId删除海报信息
     * @param id
     */
    @Override
    public void removeSkuPosterBySkuId(Long id) {
        LambdaQueryWrapper<SkuPoster> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SkuPoster::getSkuId,id);
        skuPosterMapper.delete(wrapper);
    }


    /**
     * 根据skuIds批量删除商品海报信息
     * @param ids
     */
    @Override
    public void removeSkuPosterBySkuIds(List<Long> ids) {
        LambdaQueryWrapper<SkuPoster> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SkuPoster::getSkuId,ids);
        skuPosterMapper.delete(wrapper);
    }
}
